package org.tp;

import java_cup.runtime.*;
import java.io.*;

%%
%class TpLexer
%line
%column
%cupsym TpSymbol
%cup

%{
private Symbol symbol (int type) {
    return new Symbol (type, yyline, yycolumn);
}

private Symbol symbol (int type, Object value) {
    return new Symbol (type, yyline, yycolumn, value);
}
%}

Identifier	= [a-zA-Z][a-zA-Z0-9_]*
LineTerminator	= \r|\n|\r\n
WhiteSpace	= {LineTerminator} | [ \t\f]
Integer		= [0-9]+
Float		= [0-9]+\.[0-9]+
String		= \"[^\"]*\"

%%


/* -------------------------------------------------
	Separateurs Operateurs
   ------------------------------------------------- */

"("	{/*System.out.print(yytext());*/  return symbol(TpSymbol.LPAR); }
")"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.RPAR); }
"{"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.LBRACE); }
"}"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.RBRACE); }
"["	{/*System.out.print(yytext());*/  return symbol(TpSymbol.LBRACKET); }
"]"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.RBRACKET); }
"&&"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.AND); }
"||"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.OR); }
"<"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.LT); }
">"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.GT); }
"<="	{/*System.out.print(yytext());*/  return symbol(TpSymbol.LE); }
">="	{/*System.out.print(yytext());*/  return symbol(TpSymbol.GE); }
"!="	{/*System.out.print(yytext());*/  return symbol(TpSymbol.DIFF); }
"!"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.NOT); }
"="	{/*System.out.print(yytext());*/  return symbol(TpSymbol.EQ); }
"++"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.PLUSPLUS); }
"+"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.PLUS); }
"--"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.MOINSMOINS); }
"-"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.MINUS); }
"*"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.MULT); }
"/"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.DIV); }
";"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.SEMIC); }
":="	{/*System.out.print(yytext());*/  return symbol(TpSymbol.AFF); }
":"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.COLON); }
"%"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.MODULO); }
"if"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.IF); }
"else"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.ELSE); }
"while"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.WHILE); }
"var"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.VAR); }
"int"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.INT); }
"float"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.FLOAT); }
"char"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.CHAR); }
"string"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.STRING); }
"of"	{System.out.print(yytext());  return symbol(TpSymbol.OF); }
","	{/*System.out.print(yytext());*/  return symbol(TpSymbol.COMA); }
"struct"	{/*System.out.print(yytext());*/  return symbol(TpSymbol.STRUCT); }
"function"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.FUNC); }
"procedure"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.PROC); }
"list"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.LIST); }
"bool"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.BOOLEAN); }
"for"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.FOR); }
"in"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.IN); }
"repeat"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.REPEAT); }
"return"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.RETURN); }
"null"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.NULL); }
"case"  {System.out.print(yytext());  return symbol(TpSymbol.CASE); }
"map"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.MAP); }
"enum"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.ENUM); }
"."  {System.out.print(yytext());  return symbol(TpSymbol.POINT); }
"class"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.CLASS); }
//"this"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.THIS); }
"operator"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.OPERATOR); }
"set"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.SET); }
"static"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.STATIC); }
"array"  {/*System.out.print(yytext());*/  return symbol(TpSymbol.ARRAY); }


/* -------------------------------------------------
	Variables, Entiers
   ------------------------------------------------- */

{Identifier}	{System.out.print(yytext());  return symbol(TpSymbol.IDENTIFIER, yytext()); }
{Integer}	{System.out.print(yytext());  return symbol(TpSymbol.INTEGER, yytext()); }
{Float}	{System.out.print(yytext());  return symbol(TpSymbol.REAL, yytext()); }
{String}	{System.out.print(yytext());  return symbol(TpSymbol.STRINGEXP, yytext()/*.substring(1, yytext().length()-1)*/ ); }

/* -------------------------------------------------
	Commentaires - Caracteres non pris en compte
   ------------------------------------------------- */
{WhiteSpace}                   { /*System.out.print(yytext());*/  /* ignore */ }

/* -------------------------------------------------
	Autres signes
   ------------------------------------------------- */
.	{ /* ignore */ }
